home *** CD-ROM | disk | FTP | other *** search
- on mouseUp
- global gMosaicMap, gMosaicCount, gMosaicX, gMosaicY, gHalfTileSizeX, gHalfTileSizeY
- set whichSprite to the clickOn
- set newTile to findEmptyTile(whichSprite)
- if newTile < 1 then
- beep()
- else
- set the locH of sprite whichSprite to the locH of sprite (10 + newTile)
- set the locV of sprite whichSprite to the locV of sprite (10 + newTile)
- set swapTile to spriteToTile(whichSprite - 20)
- put char swapTile of gMosaicMap into char newTile of gMosaicMap
- put "X" into char swapTile of gMosaicMap
- updateStage()
- put gMosaicMap
- end if
- end
-
- on findEmptyTile whichSprite
- global gMosaicMap, gMosaicCount, gMosaicX, gMosaicY, gHalfTileSizeX, gHalfTileSizeY
- set foundTile to 0
- set findSprite to spriteToTile(whichSprite - 20)
- set s to findSprite - 1
- if s > 0 then
- if char s of gMosaicMap = "X" then
- set foundTile to s
- end if
- end if
- set s to findSprite + 1
- if s < (gMosaicCount + 1) then
- if char s of gMosaicMap = "X" then
- set foundTile to s
- end if
- end if
- set s to findSprite - 2
- if s > 0 then
- if char s of gMosaicMap = "X" then
- set foundTile to s
- end if
- end if
- set s to findSprite + 2
- if s < (gMosaicCount + 1) then
- if char s of gMosaicMap = "X" then
- set foundTile to s
- end if
- end if
- if (findSprite = 2) and (foundTile = 3) then
- set foundTile to 0
- end if
- if (findSprite = 4) and (foundTile = 5) then
- set foundTile to 0
- end if
- return foundTile
- end
-
- on spriteToTile whichSprite
- global gMosaicMap
- set mappedTile to offset(numToChar(whichSprite + 64), gMosaicMap)
- return mappedTile
- end
-